# jQuery pagecreate Event

jQuery Mobile Events

## Example

Alert some text when the page has been created, but before enhancement is complete:

$(document).on("pagecreate",function(){
alert("pagecreate event fired!")
});
Try it yourself »

## Definition and Usage

The pagecreate event is triggered when the page has been created in the DOM (via ajax or other), but before jQuery Mobile has finished enhancing the page.

Use this event instead of the jQuery DOM ready() method to place all other jQuery events and functions, because it will work whether the page is loaded directly or through the AJAX call of another page. Note: Before version 1.4, we used the pageinit event (deprecated) to handle this.

Note: This event is only triggered once per "page" - Every time a page is loaded for the first time, jQuery Mobile caches pages in the DOM (memory), so when you navigate back from pagetwo to pageone (for example), this event will not fire, because then, pageone is already initialized.

Tip: This event is also useful for user's that want to create their own custom widget enhancement:

$(document).on("pagecreate","#pagetwo",function(event){
$.(":jqmData(role='my-plugin')").myPlugin();
});

Related events:

- pagebeforecreate - triggered when the page is about to be initialized, but before enhancement has begun

## Syntax

To trigger the event for all pages in jQuery Mobile:

$("document").on("pagecreate",function(event){...}) Try it

To trigger the event for a specific page:

$("document").on("pagecreate","page",function(event){...}) Try it

Parameter | Description
--- | ---
function(event) | Required. Specifies the function to run when the pagecreate event occurs The function has an optional event object, which can contain any jQuery event properties (e.g. event.target, event.type, etc.) See jQuery Events Reference for more information.
page | Optional. Points to the id of the page to specify the pagecreate event for. For internal pages, use #id. For external pages, use externalfile.html.

## Try it Yourself - Examples

A demonstration of pagebeforecreate and pagecreate
A demonstration that shows when pagebeforecreate and pagecreate fire.

The event object
Using the event.type property to return the triggered event type.

jQuery Mobile Events

### WEB HOSTING

UK Reseller Hosting

### WEB BUILDING

FREE Website BUILDER Free HTML5 Templates

### W3SCHOOLS EXAMS

HTML, CSS, JavaScript, PHP, jQuery, XML, and ASP Certifications

### SHARE THIS PAGE

### Color Picker

### HTML/CSS

HTML Tutorial HTML5 Tutorial CSS Tutorial CSS3 Tutorial Bootstrap Tutorial

### JavaScript

JavaScript Tutorial jQuery Tutorial jQuery Mobile Tutorial AngularJS Tutorial AJAX Tutorial JSON Tutorial

### Graphics

Canvas Tutorial SVG Tutorial Google Maps Tutorial

### Server Side

SQL Tutorial PHP Tutorial ASP Tutorial ASP.NET Tutorial VBScript Tutorial AppML Tutorial

### Web

Web Building Web Statistics Web Certification

### XML

XML Tutorial DTD Tutorial Schema Tutorial XML DOM Tutorial XPath Tutorial XSLT Tutorial XQuery Tutorial XSL-FO Tutorial RSS Tutorial WSDL Tutorial

### HTML/CSS

HTML Tag Reference HTML Event Reference HTML Color Reference CSS 1,2,3 Reference Bootstrap Reference

### JavaScript

JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference Google Maps Reference

### Server Side

PHP Reference SQL Reference ASP Reference VBScript Reference Razor Reference ASP.NET Reference

### XML

XML DOM Reference XSLT Reference XSL-FO Reference XPath Reference XQuery Reference Schema Reference RSS Reference SVG Reference

### HTML Charsets

HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8

### HTML/CSS

HTML Examples CSS Examples

### Browser Scripting

JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples

### Server Scripting

PHP Examples ASP Examples VBScript Examples Razor Examples .NET Examples

### XML Languages

XML Examples DTD Examples XML DOM Examples XSL Examples XSLT Examples XPath Examples XQuery Examples Schema Examples RSS Examples SVG Examples